import Vue from 'vue';
import Router from 'vue-router';
//定懒加载方式的路由
const Login  = resolve => require(['@/components/auth/login.vue'], resolve);//登录
const Base   = resolve => require(['@/components/layout/base.vue'], resolve);//共有布局
//主页
const Chumo  = resolve => require(['@/components/index/chumo.vue'], resolve);//公众登录
const Shendu = resolve => require(['@/components/index/shendu.vue'], resolve);//公众登录
const Wei    = resolve => require(['@/components/index/wei.vue'], resolve);//公众登录
const Chibian= resolve => require(['@/components/index/chibian.vue'], resolve);//公众登录
//用户
const User   = resolve => require(['@/components/user/index.vue'], resolve);//用户管理

const Error404= resolve => require(['@/components/page/404.vue'], resolve);//404

Vue.use(Router);
export const constantRouterMap= [
    {path: '/', name: 'Login', component: Login, meta: {title: '登录', login:true}},
    {
        path: '/',
        component: Base,
        children:[
            {
                path: '/error/404',
                meta: {title:'404',show:false},
                component: Error404,
            },
        ],
    }
];
//异步挂载的路由
export const asyncRouterMap = [
    {
        path: '/',
        component: Base,
        children:[
            {
                path: '/chumo',
                name: 'Chumo',
                meta: {title:'触摸重庆',show:true,'icon':'fa fa-bitcoin'},
                component: Chumo,
            },
            {
                path: '/shendu',
                name: 'Shendu',
                meta: {title:'深度重庆',show:true,'icon':'fa fa-inr'},
                component: Shendu,
            },
            {
                path: '/wei',
                name: 'Wei',
                meta: {title:'微重庆',show:true,'icon':'fa fa-rupee'},
                component: Wei,
            },
            {
                path: '/chibian',
                name: 'Chibian',
                meta: {title:'吃遍重庆',show:true,'icon':'fa fa-try'},
                component: Chibian,
            },
            {
                path: '/user',
                name: 'User',
                meta: {title:'用户管理',show:true,'icon':'fa fa-user'},
                component: User,
            },
        ],
    },
    { path: '*',name:'404', redirect: '/error/404',meta: {show:false}, }
]
//实例化vue的时候只挂载constantRouter
export default new Router({
    mode: 'history',
    routes: constantRouterMap
});